<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	    <meta name="description" content="">
	    <meta name="author" content="">
<title></title>

<!-- 分页 -->
<link rel="stylesheet" href="layui/css/layui.css" media="all">
<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
<style type="text/css"></style>

 <!-- Bootstrap core CSS -->
	    <link href="dhcss/bootstrap.min.css" rel="stylesheet">
	    <!-- Additional CSS Files -->
	    <link rel="stylesheet" href="dhcss/fontawesome.css">
	    <link rel="stylesheet" href="dhcss/templatemo-style.css">
	    <link rel="stylesheet" href="dhcss/owl.css">
	    
	
	    
	    
	    <style>
	    	.zuowei{
				margin-left: 400px;
				margin-top: 0px;
				background-color: #565656;
			}
			.tinfo{
				width: 200px;
				white-space: nowrap;
				text-overflow: ellipsis;
				overflow: hidden;
			}
			
			#demo7{
				margin-left: 300px
			}
			#myinput{
				margin-left: -100px;
			}
			
		</style>
</head>


<body>
 <div id="wrapper"> 
<div id="main">
   <div class="inner" style="">
   		
   		 <!-- Header -->
          <header id="header">
           <div class="logo">
           <div id="myinput">
           <form class="form-search" action="GongGaoServlet?op=all"
						method="post">
           		<input    class="input-medium search-query"   style="height: 40px;width: 300px" name="keywords"
							id="keywords" type="text" value="${keywords}"
							placeholder="关键字..." /> &nbsp;&nbsp;
						<button type="submit" class="btn">查找</button>
						</form>
           </div>
              <a class="zuowei"  href="http://demo.qfpffmp.cn/cssthemes6/dgmg_38_ramayana/index.html">公告信息</a>
           </div>
         </header>
   		
   		<!-- 主体 -->
		<section class="tables">
	<div class="container">
		

		<hr>
		<div class="row clearfix">
			<div class="col-md-12 column">
				<div class="layui-form">
			    <form class="form-search" action="GongGaoServlet?op=all"
						method="post">
						<input class="input-medium search-query" name="keywords"
							id="keywords" type="text" value="${keywords}"
							placeholder="关键字..." /> &nbsp;&nbsp;
						<button type="submit" class="btn">查找</button>
					</form>
			   
			</div>

				<table class="table table-bordered table-hover">
					<thead>
						<tr class="info">
							<th>公告号</th>
							<th>管理员编号</th>
							<th>发布时间</th>
							<th>公告状态</th>
							<th>公告内容</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						<c:if test="${pd==null}">
							<c:redirect url="GongGaoServlet?op=all"></c:redirect>
						</c:if>
						<c:if test="${pd!=null }">
							<c:forEach items="${pd.data }" var="gg">
								<tr class="success">
									<td class="id">${gg.tid }</td>
									<td>${gg.ano }</td>
									<td>${gg.tdate }</td>
									<td>${gg.tstatus }</td>
									<td>${gg.tinfo }</td>
									<td><a class="updateTC" href="#">修改</a>&nbsp;|&nbsp; <a
										class="delAnn" href="#">删除</a>&nbsp;|&nbsp; <a
										class="clickLook" href="#">查看详情</a></td>
								</tr>
							</c:forEach>
						</c:if>
					</tbody>
				</table>

			</div>
		</div>
		<!-- 分页 -->
		<div id="demo7">这里是分页</div>
	</div>
	
	</section>
        
	</div>
</div>
<%@include file="daohang.jsp" %>
</div>  

		
       
	<script src="${pageContext.request.contextPath}/js/jquery-2.0.3.js"></script>


    <!-- ssss -->
         <!-- Scripts -->
  <!-- Bootstrap core JavaScript -->

    <script src="dhjs/browser.min.js.下载"></script>
    <script src="dhjs/breakpoints.min.js.下载"></script>
    <script src="dhjs/transition.js.下载"></script>
    <script src="dhjs/owl-carousel.js.下载"></script>
    <script src="dhjs/custom.js.下载"></script>

	<!--分页操作 2- 引入layui.js文件 -->
	<script src="layui/layui.js" charset="utf-8"></script>
	<script>
	layui.use(['laypage', 'layer'], function(){
		  var laypage = layui.laypage
		  ,layer = layui.layer;
		  
		//完整功能
		  laypage.render({
		    elem: 'demo7' // 分页的导航在哪里显示，pagediv是层id
		    ,theme: '#428bca'  //颜色
		    ,count: ${pd.totalCount} //总记录数
		    ,curr: ${pd.page}  //当前页
		    ,limit: ${pd.pageSize}//当前页显示的记录数
		    ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
		    ,jump: function(obj, first){ //跳转页面时候的动作
			    //obj包含了当前分页的所有参数，比如：
			    // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
			   // console.log(obj.limit); //得到每页显示的条数
			    
			    //首次不执行
			    if(!first){
			      //do something
			       location.href="GongGaoServlet?op=all&page="+obj.curr+"&pagesize="+obj.limit+"&keywords="+$("#keywords").val();
			    }
			  }
		  });
		  
		  //点击查看详情
		   $(".tinfo").mouseover(function(){
			  layer.tips(
					  
					  $(this).text(), this, {
						  skin: 'demo-class',
						  tips: [1, '#3595CC'],
						  time: 4000
						}			
			  );  
			  
		  }); 
		  
		  //点击修改-->弹窗
		  $(".updateTC").click(function() {
			  var tid = $(this).parents("tr").find("td").eq(0).text();
			  layer.open({
				  type: 2,
				  skin: 'layui-layer-demo', //样式类名
				  closeBtn: 1, //不显示关闭按钮
				  anim: 2,
				  shadeClose: true, //开启遮罩关闭
				  content: 'GongInline.jsp?id='+tid,
				  area: ['500px', '500px']
				});
		});
		  
		 //点击删除--》
		 $(".delAnn").click(function(){
			var tid = $(this).parents("tr").find("td").eq(0).text();
			//询问框
			layer.confirm('确认删除吗？', {
			  btn: ['确认','取消'] //按钮
			}, function(){
				 $.ajax({
		        	 url:"GongGaoServlet",
		             type: "post",
		             data: {
		            	 tid:tid,
		            	 op:"delByTid"
		             },
		             dataType: "json",
		             success: function(res){
		            	 console.log("res:"+res);
		            	 if(res==true){
		            		 layer.alert('删除成功！', {
		            			 icon: 2,
		            			 yes: function(layero, index){
									  location.href="GongGaoServlet?op=all";
									}
		            			 });
		            		 console.log("应该是这里啊");
		            		 layer.msg('删除成功！', {icon: 1});
		            	 }else{
		            		 layer.msg('删除失败！', {
		            			 icon: 1,
		            			 yes: function(layero, index){
									  location.href="GongGaoServlet?op=all";
									}
		            			});
		            	 }
                      }
		         });
			  
			});
		 });
		  //点击查看详情
		  //小tips
	
		$(".clickLook").click(function() {
			  var tinfo = $(this).parents("tr").find("td").eq(4).text();
			  layer.msg(tinfo);
		});

		  //结束
		});
	</script>


</body>
</html>